package com.i2works.smartluolong.api.config;


import com.i2works.smartluolong.api.utils.SessionAuthInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * web配置，相当于（web.xml）
 *
 * @author Liu Yutao <koal@vip.qq.com>
 * @date 2017/12/15 10:22
 */
@Configuration
public class WebAdapterConfiguration extends WebMvcConfigurerAdapter {
    //日志
    private static final Logger logger = LoggerFactory.getLogger(WebAdapterConfiguration.class);

    /**
     * 注册拦截器
     * addPathPatterns 用于添加拦截规则
     * excludePathPatterns 用户排除拦截
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //授权认证拦截器
        registry.addInterceptor(new SessionAuthInterceptor()).addPathPatterns("/**");
        logger.info("注册 --> 授权认证拦截器(ResubmitInterceptor)....");
        super.addInterceptors(registry);
    }


}
